package com.landinfo.service.mapper;

import com.landinfo.domain.Region;
import com.landinfo.service.dto.RegionDTO;
import org.mapstruct.Mapper;

import java.util.List;

/**
 * Mapper for the entity Region and its DTO RegionDTO.
 */
@Mapper(componentModel = "spring", uses = {})
public interface RegionMapper {

    //@Mapping(source = "parentid.id", target = "parentidId")
    //@Mapping(source = "parentid.parent", target = "parentidParent")
    RegionDTO regionToRegionDTO(Region region);

    List<RegionDTO> regionsToRegionDTOs(List<Region> regions);

    //@Mapping(target = "Children", ignore = true)
    //@Mapping(source = "parentidId", target = "parentid")
    Region regionDTOToRegion(RegionDTO regionDTO);

    List<Region> regionDTOsToRegions(List<RegionDTO> regionDTOs);

    default Region regionFromId(String id) {
        if (id == null) {
            return null;
        }
        Region region = new Region();
        region.setId(id);
        return region;
    }
}
